<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>转发</title>
    <#include "/pubHeadStyle.html">
</head>
<body>

<div id="forwardDiv" style="margin: 20px;">
    <form class="layui-form" action="">
        <table class="layui-table">
            <tr>
                <td>接收人:</td>
                <td>
                    <input type="hidden" name="titleHidden" readonly  >
                    <!--TODO 选择用户过多，名称展示不全-->
                    <input type="text" name="title" readonly  autocomplete="off" placeholder="请选择接收人" class="layui-input" style="width: 70%;display: inline">
                    <button type="button" class="layui-btn run layui-btn-sm" id="selectUsers">选择</button>
                </td>
            </tr>
            <tr>
                <td>提醒消息方式:</td>
                <td>
                    <!--通知方式-->
                    <div class="layui-input-inline">
                        <#list handlersMap?keys as key>
                        <input type="checkbox" class="layui-input" lay-filter="informType" name="informType" lay-skin="primary" value="${key}" checked="checked"  />
                        <span style="line-height: 44px;">
                            ${handlersMap[key].title }
                        </span>
                    </#list>
</div>
</td>
</tr>
<tr>
    <td>转发意见:</td>
    <td><textarea  name="suggestion" placeholder="请输入转发意见" class="layui-textarea"></textarea></td>
</tr>
</table>
</form>
</div>
<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','setter','table','form','util'], function(){
        var setter = layui.setter;
        var table = layui.table;
        var util = layui.util;
        var $ = layui.$;
        var dataPrivacyLevel = '${dataPrivacyLevel}';

        //接收人的人员选择器
        $("#selectUsers").click(function () {
            var body;
            var userSelectorWin;
            var that = $("#forwardDiv table [name='title']");
            var thatHidden = $("#forwardDiv table [name='titleHidden']");
            parent.layer.open({
                type: 2,
                title: '人员选择器',
                area: ['980px', '520px'],
                btn:["保存","取消","撤销"],
                resize: false,
                content:serverPath.systemPath+setter.sysLinkPath+ "dialog/view/sysUserDialog?dataPrivacyLevel=" + dataPrivacyLevel,
                success: function (layero, index) {
                    body = parent.layer.getChildFrame('body',index);
                    userSelectorWin = parent.window[layero.find('iframe')[0]['name']];
                    userSelectorWin.layui.userList = [];
                    if (that != null && that.val()) {
                        var hiddenDataArr = thatHidden.val().split(",");
                        var theDataArr = that.val().split(",");
                        $.each(hiddenDataArr,function (k,v) {
                            var userListObj={};
                            userListObj.name = theDataArr[k];
                            userListObj.userId = v;
                            userSelectorWin.layui.userList.push(userListObj);
                        })
                    }
                },
                yes: function (index, layero) {
                    //用户选择器返回的选择人员数组[{name:"name1",userId:"userId1"},{name:"name2",userId:"userId2"}...]
                    var theUserList = body.find("input[name=userList]").val();
                    var itemId="";
                    var itemName="";
                    if(theUserList){
                        layui.each(JSON.parse(theUserList), function (index, item) {
                            itemId  += item.userId+",";
                            itemName+= item.name+",";
                        });
                    }
                    if (itemName.length > 0) {
                        //用户ID
                        thatHidden.val( itemId.substr(0, itemId.length - 1) );
                        //用户姓名
                        that.val( itemName.substr( 0, itemName.length - 1) );
                    }
                    parent.layer.close(index);
                },
                btn3:function (index, layero) {
                    userSelectorWin.cancelData(index);
                    return false;//开启该代码可禁止点击该按钮关闭
                }
            });
        });
    });

</script>
</body>
</html>